<template>
	<view class="periphery">
		<comHead :title="$t('grzx.zbzl')" :isLeft="true" :isRight="false"></comHead>
		<view class="tips">{{$t('index.dhhzpbtbh')}}</view>
		<view class="list">
			<view class="item" v-for="(item, index) in perList">
				<view class="top">
					<text>{{$t('index.zpdhsj')}}:{{item.create_time}}</text>
					<text style="text-align: center;">{{item.status==1?$t('index.dfh'):item.status==2?$t('index.yfh'):$t('index.ysh')}}</text>
				</view>
				<view class="c">
					<view class="imageBox">
						<image src="https://siha.vxmeng.com/static/index/gift-img.png" mode="widthFix"></image>
						<image :src="getImg(item.image)" mode="widthFix"></image>
					</view>
					<view class="info">
						<text class="name">{{item.name}}</text>
						<view class="blurb">{{item.blurb}}</view>
						<view class="price">
							<image :src="getImg('/static/index/dou.png')" mode="widthFix"></image>
							{{item.money}}
						</view>
					</view>
				</view>
				<view class="bot">
					<view class="btn" @click="comLink('/pages/index/merchInfo?id='+item.id)">{{$t('index.ddxq')}}</view>
					<view class="btn" @click="openPop(item)">{{$t('index.qrsh')}}</view>
				</view>
			</view>
		</view>
		
		<view class="giftPop" v-if="isHarvest">
			<view class="box">
				<view class="imgs">
					<image src="https://siha.vxmeng.com/static/index/gift-img.png" mode="widthFix"></image>
					<image :src="getImg(currentPeriphery.image)" mode="widthFix"></image>
				</view>
				<view class="info">
					<text class="name">{{$t('index.qrsdhlm')}}</text>
					<text class="intro">{{$t('index.qrshhcdd')}}</text>
					<view class="btns">
						<view class="f" @click="isHarvest=false">{{$t('grzx.qx')}}</view>
						<view class="t" @click="comfirm()">{{$t('index.qrsh')}}</view>
					</view>
				</view>
				<image class="close" @click="isHarvest = false" src="https://siha.vxmeng.com/static/index/close.png" mode="widthFix"></image>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				isHarvest: false,
				currentPeriphery: {
				},
				perList:[],
			}
		},
		onShow() {
			this.getUserOrderList()
		},
		methods: {
			async getUserOrderList() {
				const res = await this.$myRequest({
					url: 'api/order/getUserOrderList',
					data: {
						page:1,
						page_size:15
					}
				})
				if (res.code == 1) {
					console.log(res)
					this.perList = res.data.list
				}
			},
			openPop(item){
				this.currentPeriphery = item
				this.isHarvest = true
			},
			async comfirm(){
				const res = await this.$myRequest({
					url: 'api/order/editUserOrder',
					data: {
						user_order_id:this.currentPeriphery.id
					}
				})
				if (res.code == 1) {
					console.log(res)
					this.isHarvest = false
					this.$tools.showTx(res.msg)
					this.getUserOrderList()
				}
			}
		}
	}
</script>

<style lang="less" scoped>
	.periphery{
		height: 100vh;
		overflow: auto;
		.tips{
			height: 64rpx;
			background: linear-gradient(274deg, #62B6FC 1%, #5F58FD 78%, #5F58FD 99%);
			color: #fff;
			text-indent: 30rpx;
			font-size: 24rpx;
			line-height: 64rpx;
		}
		.list{
			height: calc(100vh - 266rpx);
			padding: 0 30rpx;
			overflow: auto;
			color: #fff;
			.item{
				height: 420rpx;
				border-radius: 30rpx;
				margin-top: 18rpx;
				background: linear-gradient(137deg, #1C3C70 14%, #56084C 87%);
				.top{
					padding: 0 30rpx;
					height: 98rpx;
					font-size: 28rpx;
					display: flex;
					align-items: center;
					justify-content: space-between;
				}
				.c{
					display: flex;
					justify-content: space-between;
					align-items: center;
					padding: 40rpx 30rpx;
					height: 238rpx;
					.imageBox{
						width: 240rpx;
						height: 132rpx;
						border-radius: 20rpx;
						overflow: hidden;
						position: relative;
						display: flex;
						justify-content: center;
						align-items: center;
						image{
							width: 240rpx;
							position: absolute;
							&:last-child{
								width: 128rpx;
								// position: absolute;
								// top: 12rpx;
								// left: 30%;
							}
						}
					}
				}
				.info{
					flex: 1;
					padding: 0 10rpx;
					display: flex;
					height: 150rpx;
					flex-direction: column;
					justify-content: space-between;
					.blurb{
						width: 390rpx;
						overflow: hidden;
						text-overflow: ellipsis;
						white-space: nowrap;
						font-size: 24rpx;
					}
					image{
						width: 50rpx;
						position: static;
						vertical-align: middle;
					}
				}
				.bot{
					width: 100%;
					height: 84rpx;
					display: flex;
					border-top: 2rpx solid rgb(97,97,122);
					.btn{
						width: 50%;
						text-align: center;
						line-height: 84rpx;
						border-right: 2rpx solid rgb(97,97,122);
						&:last-child{
							border: none;
						}
					}
				}
			}
		}
		.giftPop{
			position: fixed;
			width: 100vw;
			height: 100vh;
			top: 0;
			left: 0;
			z-index: 102;
			color: #fff;
			background-color: rgba(0, 0, 0, .6);
			.box{
				width: 570rpx;
				height: 720rpx;
				position: absolute;
				top: 50%;
				left: 50%;
				transform: translate(-50%, -50%);
				.imgs{
					position: relative;
					font-size: 0;
					image{
						&:first-child{
							width: 100%;
						}
						&:last-child{
							width: 300rpx;
							position: absolute;
							top: 20rpx;
							left: 160rpx;
						}
					}
				}
				.info{
					display: flex;
					flex-direction: column;
					align-items: center;
					height: 312rpx;
					border-radius: 0 0 24rpx 24rpx;
					background: linear-gradient(137deg, rgb(28,60,122) 14%, rgb(86,8,102) 87%);
					.name{
						font-size: 30rpx;
						margin-top: 30rpx;
					}
					.intro{
						font-size: 26rpx;
						margin-top: 20rpx;
					}
					.price{
						width: 180rpx;
						height: 60rpx;
						background: #7973D7;
						margin-top: 30rpx;
						font-size: 20rpx;
						display: flex;
						justify-content: center;
						align-items: center;
						border-radius: 20rpx;
						overflow: hidden;
						position: relative;
						image{
							width: 20rpx;
							margin-right: 20rpx;
						}
						text{
							&:last-child{
								font-size: 16rpx;
								position: absolute;
								top: 0;
								right: 0;
								background: linear-gradient(109deg, rgba(48, 126, 254, 0.7569) 19%, #D614FF 83%);
								width: 80rpx;
								height: 20rpx;
								line-height: 20rpx;
							}
						}
					}
					.btns{
						display: flex;
						justify-content: center;
						height: 80rpx;
						margin-top: 50rpx;
						view{
							width: 250rpx;
							font-size: 30rpx;
							text-align: center;
							line-height: 80rpx;
							border-radius: 40rpx;
						}
						.f{
							margin-right: 20rpx;
							border: 2rpx solid #62B6FC;
						}
						.t{
							background: linear-gradient(285deg, #62B6FC 0%, #5F58FD 77%, #5F58FD 98%);
						}
					}
				}
			}
			.close{
				width: 50rpx;
				display: block;
				margin: 20rpx auto;
			}
		}
		
	}
</style>
